package mornd;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @author: mornd
 * @dateTime: 2023/5/4 - 18:09
 * 构造器->依赖注入(@Autowired标注)->初始化方法init->销毁方法destroy
 */

@Component
public class Animal {
    public Animal() {
        System.out.println("Animal 构造器");
    }

    @Autowired
    public void autowire(@Value("${name}") String name) {
        System.out.println("依赖注入：" + name);
    }

    @PostConstruct
    public void init() {
        System.out.println("初始化方法");
    }

    @PreDestroy
    public void destroy() {
        System.out.println("销毁方法");
    }

}
